package com.augurit.gzcgwsp.csshlj.web;

import java.io.File;
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.script.ScriptEngine;
import javax.servlet.http.HttpServletRequest;
import net.sf.json.JSONObject;
import org.apache.log4j.Logger;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.jbpm.api.JbpmException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springside.modules.orm.Page;
import org.springside.modules.web.struts2.Struts2Utils;
import com.augurit.common.base.action.BaseAction;
import com.augurit.common.base.action.CrudActionSupport;
import com.augurit.common.system.web.auth.form.LoginUserForm;
import com.augurit.common.util.lang.StringUtils;
import com.augurit.gzcgwsp.commonex.util.lang.DateUtilsEX;
import com.augurit.gzcgwsp.csshlj.form.ShljYsForm;
import com.augurit.gzcgwsp.csshlj.service.ICsshljCzService;
import com.augurit.gzcgwsp.csshlj.service.IShljYsService;
import com.augurit.gzcgwsp.printDoc.service.IYwPrintDocService;
import com.augurit.gzcgwsp.printDoc.web.form.YwPrintDocForm;
import com.augurit.gzcgwsp.smartformCsdlwj.common.SmartDao;
import com.augurit.gzcgwsp.smartformCsdlwj.service.ISmartFormShljqsService;
import com.augurit.gzcgwsp.smartformCsdlwj.service.IYwHwXminfoService;
import com.augurit.gzcgwsp.wfex.app.doc.IOaDocCodeServiceEX;
import com.augurit.gzcgwsp.wfex.bi.service.IWfBusTemplateServiceEX;
import com.augurit.gzcgwsp.wfex.bi.service.IWfTemplateAttachmentRefServiceEX;
import com.augurit.gzcgwsp.wfex.bi.web.form.WfTemplateAttachmentRefFormEX;
import com.augurit.gzcgwsp.wfex.common.util.WfUtilsEX;
import com.augurit.smartform.factory.ScriptEngineFactory;
import com.augurit.smartform.service.IFormExecuteService;
import com.augurit.smartform.test.TestService;
import com.augurit.wf.bi.web.form.WfActElemPrivDefForm;
import com.augurit.wf.bi.web.form.WfBusInstanceTaskForm;
import com.augurit.wf.common.constant.WfConstant;
import com.augurit.wf.common.form.TraceRecord;
import com.augurit.wf.common.form.WfBusSaveResult;
import com.augurit.wf.common.service.IWfService;
import com.augurit.wf.common.util.WfUtils;
import com.augurit.wf.common.web.WfBusClientExtAction;
/**
 * 水域
 * @author Administrator
 *
 */
@SuppressWarnings( { "serial", "unchecked" })
@Results( {
		@Result(name ="printViewZs", location ="/gzcgwsp/shljys/preViewXkz.jsp"),
		@Result(name ="printViewfb", location ="/gzcgwsp/shljys/preViewfb.jsp"),
		@Result(name ="printViewfb2", location ="/gzcgwsp/shljys/preViewfb2.jsp"),
		@Result(name = "printxkzs", location = "/gzcgwsp/wfex/client/wf-printExcelEx.jsp"),
		@Result(name = "printfb", location = "/gzcgwsp/wfex/client/wf-printExcelEx.jsp"),
		@Result(name = CrudActionSupport.RELOAD, location = "shlj-ys.action", type = "redirect"),
		@Result(name = WfConstant.PRINT, location = WfConstant.PRINT_JSP),
		@Result(name = WfConstant.PRINT_DIR, location = WfConstant.PRINT_DIR_JSP),
		@Result(name = WfConstant.MAKE_DOCUMENT, location = "/gzcgwsp/wfex/client/common/make-noline-document.jsp") })
public class ShljYsAction extends WfBusClientExtAction{
	private static final Logger log=Logger.getLogger(ShljYsAction.class);
	@Autowired
	private TestService testService;	
	@Autowired
	private ISmartFormShljqsService smartFormShljqsService;
	@Autowired
	private IFormExecuteService formExecuteService;	
	@Autowired
	private IWfTemplateAttachmentRefServiceEX wfTemplateAttachmentRefServiceEX;
	@Autowired
	private IOaDocCodeServiceEX oaDocCodeServiceEX;
	@Autowired
	private SmartDao smartDao;
	@Autowired
	private IWfBusTemplateServiceEX wfBusTemplateServiceEX;
	@Autowired
	private IShljYsService shljYsService;
	@Autowired
	private ICsshljCzService csshljCzService;	
	@Autowired
	private IYwPrintDocService ywPrintDocService;
	@Autowired
	private IWfService wfService;
	@Autowired
	private IYwHwXminfoService ywHwXminfoService;

	private Page<Map> page = new Page<Map>(20);
	private Map pageMap = new HashMap();

	private ShljYsForm form;
	private Long id;

	/**
	 * 流程的保存
	 */
	@Override
	public String wfBusSave() throws Exception {
		this.executeWfSaveServer(); // 保存之前执行后端JS函数
		try {	
			Map map = getMapByRequest(getRequest());
			String username=this.getLoginUser().getUser().getUserName();
			WfBusInstanceTaskForm task=shljYsService.wfBusSave(getRequest(),form,map,username);
			if(task==null){
				Struts2Utils.renderJson("{\"success\":false,\"errorMsg\":\"" + "保存失败请确认是否有此权限" + "\"}");
				return null;
			}
			
			WfUtils.renderWfBusSaveJson(task, form);
		} catch (Exception e) {
			WfBusSaveResult result = new WfBusSaveResult(true, "保存失败");
			Struts2Utils.renderJson(result);
			log.error("保存出现错误"+e);
			e.printStackTrace();
		}
		return null;
	}
	
	/**
	 * 预受理退回
	 * @return
	 * @throws Exception
	 */
	public String wfBusYslTuih() throws Exception {
    	try {
    		shljYsService.wfBusYslTuih(form, this.getLoginUser());
			WfBusSaveResult result = new WfBusSaveResult(true, null);
			result.setTask(new WfBusInstanceTaskForm());
			Struts2Utils.renderJson(result);
		} catch (RuntimeException e) {
			e.printStackTrace();
		}
        return null;
    }

	/**
	 * 保存发证号发证信息
	 * @return
	 */
	public String saveotherInfo(){
		Map map =this.getMapByRequest(this.getRequest());
		this.shljYsService.saveOtherInf(map);
		return null;
	}
	
    /**
     * ntko控件套打许可证书
     * @return
     */
    public String printXkz() throws Exception{
        try {
            String tempPath="Templates/printTemplate/csshlj/czxkz.xls";
            logger.info("打印经营许可证的文件路径"+tempPath);
           String context=getRequest().getSession().getServletContext().getRealPath("");
           String inpath=context+File.separator+tempPath;
           tempPath=shljYsService.writeXkzData(form,context,inpath);
           getRequest().setAttribute("templateFilePath",tempPath);
           logger.info("返回设施一览表文件路径"+tempPath);
       } catch (Exception e) {
           log.error("转换模版文件出现错误");
       }
       return "printxkzs";
    }
	/**
	 * 套打副本
	 * @return
	 * @throws Exception
	 */
	public String printFb() throws Exception{
		 try {
	            String tempPath="Templates/printTemplate/csshlj/fbzs.xls";
	            logger.info("打印经营许可证的文件路径"+tempPath);
	           String context=getRequest().getSession().getServletContext().getRealPath("");
	           String inpath=context+File.separator+tempPath;
	           tempPath=this.shljYsService.writeFbData(form,context,inpath);
	           getRequest().setAttribute("templateFilePath",tempPath);
	           logger.info("返回设施一览表文件路径"+tempPath);
	       } catch (Exception e) {
	           log.error("转换模版文件出现错误");
	       }
		  return "printfb";
	  }
	
	/**
	 * 打印查看许可证书
	 * @return
	 */
	public String preViewXkz(){
	  	String taskId=getRequest().getParameter("taskId");
	  	WfBusInstanceTaskForm instance = wfService.getWfBusInstanceTaskById(Long.valueOf(taskId), this.getLoginUserName());
		String activName=instance.getActivityName();
	    getRequest().setAttribute("hjmc", activName);
	    return "printViewZs";
	}
	
	/**
	 * 打印查看副本
	 * @return
	 */
	public String printViewFb(){
		LoginUserForm uform=(LoginUserForm)this.getRequest().getSession().getAttribute("SES_LOGIN_USER");
		if(StringUtils.isBlank(form.getFzjg())){
			if(uform.getOrg().getOrgName().contains("城管局")){
				form.setFzjg(uform.getOrg().getOrgName());
			}else{
				form.setFzjg("广州市城市管理委员会");
			}
		}
		String taskId=getRequest().getParameter("taskId");
	  	WfBusInstanceTaskForm instance = wfService.getWfBusInstanceTaskById(Long.valueOf(taskId), this.getLoginUserName());
		String activName=instance.getActivityName();
	    getRequest().setAttribute("hjmc", activName);
	  return "printViewfb";
	}
	
	/**
	 * 查看副本第二页
	 * @return
	 */
	public String printViewFb2(){
	    getRequest().setAttribute("hjmc", getRequest().getParameter("hjmc"));
	  return "printViewfb2";
	}
	
	/**
	 * 保存许可证
	 * @return
	 * @throws IOException 
	 */
	public String saveXkz() throws IOException{
	   try {
		   reSetForm(form);
		this.shljYsService.doUpdate(form,"SYSHLJ_V1"); 
	} catch (Exception e) {
		
	}
	getResponse().getWriter().print("success");
		return null;
	}
	
	/**
	 * 保存副本
	 * @return
	 * @throws Exception
	 */
	public String saveFb() throws Exception{
		   reSetForm(form);
			this.shljYsService.doUpdateFb(form,"SYSHLJ_V1");
			Map map=getMapByRequest(getRequest());
			ywHwXminfoService.saveByMap(map,null);
		     getResponse().getWriter().print("success");
			return null;
	}

	
	/**
	 * 保存副本第二页的项目日期信息
	 * @return
	 * @throws Exception
	 */
	public String saveFb2() throws Exception{
		   try {
				Map map=getMapByRequest(getRequest());
				ywHwXminfoService.saveByMap(map,null);
				
			} catch (Exception e) {
				
			}
			getResponse().getWriter().print("success");
			return null;
	}
//	/**
//	 * 制文
//	 * 
//	 * @return
//	 * @throws Exception
//	 */
//	public String makeDocument() throws Exception {
//		 //System.out.println(form.getId());
//		 setOpinions();
//		 String redHeadFilePath="";
//		 if (StringUtils.isNotBlank(form.getRedHeadFileId())) {
//		      redHeadFilePath = wfBusTemplateServiceEX.getPrintTemplatePath(Long.parseLong(form.getRedHeadFileId()));
//		      form.setRedHeadFilePath(redHeadFilePath);
//		 }
//		 String templateCode = getTemplateCode();
//		 if (templateCode != null && templateCode.trim().length() > 0) {
//		 String printTemplatePath = wfBusTemplateServiceEX.getPrintTemplatePath(templateCode,WfTemplateAttachmentRefFormEX.ZHENGWEN_TEMPLATE_TYPE);
//		 form.setTemplatePath(printTemplatePath);
//		 WfTemplateAttachmentRefFormEX wfTemplateAttachmentRefFormEX =(WfTemplateAttachmentRefFormEX) wfTemplateAttachmentRefServiceEX.get(Long.parseLong(form.getZhengwenFileId()));
//		 String zhengwenPath = wfTemplateAttachmentRefFormEX.getFilePath()+ "/" + wfTemplateAttachmentRefFormEX.getFileRealName();
//		 //form.setZhengwenPath(zhengwenPath);
//		 System.out.println("getZhengwenPath:" + form.getZhengwenPath());
//		 
//		 //---------行政允许------
////		 DlzyForm dlzyForm=ywDlzyService.get(form.getId());
////		 dlzyForm.setZhengwenPath(zhengwenPath);
////		 dlzyForm.setCurDate(DateUtilsEX.convertDate2Chinese(new Date()));
////		 dlzyForm.setCurYear(String.valueOf(Calendar.getInstance().get(Calendar.YEAR)));
////		 dlzyForm.setCurSeq(String.valueOf(oaDocCodeServiceEX.getCurSeqAndAddSeq(templateCode,wfTemplateAttachmentRefFormEX.getFileCode(),form.getId())));		 
////		 int betweenDays=DateUtilsEX.getDaysBetween(dlzyForm.getZysjqssj(),dlzyForm.getZysjjssj());
////		 if(betweenDays>=0) betweenDays=betweenDays+1;
////		 if(betweenDays<0) betweenDays=betweenDays-1;
////		 dlzyForm.setTian(String.valueOf(betweenDays));
////		 dlzyForm.setUsername(this.getLoginUser().getUser().getUserName());
////		 dlzyForm.setLxdh(this.getLoginUser().getUser().getMobile());
////		 //dlzyForm.setAcceptNo(dlzyForm.getBh());
////		 dlzyForm.setCsyj(form.getCsyj());
////		 dlzyForm.setFsyj(form.getFsyj());
////		 dlzyForm.setSpyj(form.getSpyj());
//		//---获取受理通知书时间---
////		 String sltjFileCode="slxzxksqtzs";  //受理通知书文件编码
////		 YwPrintDocForm ywPrintDocForm=ywPrintDocService.getSltjFile(templateCode,sltjFileCode,form.getId());
////         if(ywPrintDocForm!=null)
////        	 dlzyForm.setSlDate(DateUtilsEX.convertCommonDate(ywPrintDocForm.getCreatDate()));
////        	 
////		 WfUtilsEX.wfBusPrint(dlzyForm);		
//		    BaseAction.getRequest().setAttribute("zhengwenPath",zhengwenPath);
//		    BaseAction.getRequest().setAttribute("templateFilePath",zhengwenPath);
//			BaseAction.getRequest().setAttribute("fileCode",wfTemplateAttachmentRefFormEX.getFileCode());
//			BaseAction.getRequest().setAttribute("entityId", form.getId());
//			BaseAction.getRequest().setAttribute("templateId",wfTemplateAttachmentRefFormEX.getId());
//		 }
//		return WfConstant.MAKE_DOCUMENT;
//	}

	/**
	 * 制文
	 * 
	 * @return
	 * @throws Exception
	 */
	public String makeDocument() throws Exception {
		setOpinions();
		//加载收件通知书里面的附件
		form = shljYsService.getSjtzsField(form);
		if (StringUtils.isNotBlank(form.getRedHeadFileId())) {
			String redHeadFilePath = wfBusTemplateServiceEX
					.getPrintTemplatePath(Long.parseLong(form
							.getRedHeadFileId()));
			form.setRedHeadFilePath(redHeadFilePath);
		}
		
		//加载收件通知书里面的附件
		 String isred=getRequest().getParameter("isred");
		 //如果要打印红头
		 if("yes".equals(isred)){
			 String redHeadFilePath = wfBusTemplateServiceEX.getRedFile(form.getTemplateCode());
		      form.setRedHeadFilePath(redHeadFilePath);
		 }
		String templateCode = getTemplateCode();
		if (templateCode != null && templateCode.trim().length() > 0) {
			String printTemplatePath = wfBusTemplateServiceEX
					.getPrintTemplatePath(
							templateCode,
							WfTemplateAttachmentRefFormEX.ZHENGWEN_TEMPLATE_TYPE);
			form.setTemplatePath(printTemplatePath);
			form.setCbyw("从事水域城市生活垃圾经营性清扫、收集、运输服务许可审批");
	//		form.setFzjg("广州市城市管理委员会");
	//		form.setTzlxr(getLoginUser().getUser().getUserName());
			WfTemplateAttachmentRefFormEX wfTemplateAttachmentRefFormEX = (WfTemplateAttachmentRefFormEX) wfTemplateAttachmentRefServiceEX
					.get(Long.parseLong(form.getZhengwenFileId()));
			String zhengwenPath = wfTemplateAttachmentRefFormEX.getFilePath()
					+ "/" + wfTemplateAttachmentRefFormEX.getFileRealName();
			form.setZhengwenPath(zhengwenPath);
			String slrq=shljYsService.getSlrq(form.getId(),wfTemplateAttachmentRefFormEX.getFileCode(),wfTemplateAttachmentRefFormEX.getId());
			if(StringUtils.isBlank(slrq))
				form.setSlrq2(DateUtilsEX.convertDate2Chinese(new Date()));
			else
				form.setSlrq2(slrq);
			form.setCurDate(DateUtilsEX.convertDate2Chinese(new Date()));
			form.setCurYear(String.valueOf(Calendar.getInstance().get(
					Calendar.YEAR)));
			form.setCurSeq(String.valueOf(oaDocCodeServiceEX
					.getCurSeqAndAddSeq(templateCode,
							wfTemplateAttachmentRefFormEX.getFileCode(), form
									.getId())));
			List list = shljYsService.getListById(form.getId());
			WfUtilsEX.wfBusSmartFormPrint(form, list);
			BaseAction.getRequest().setAttribute("seq", form.getCurSeq());
			BaseAction.getRequest().setAttribute("templateFilePath",zhengwenPath);
			BaseAction.getRequest().setAttribute("fileCode",
					wfTemplateAttachmentRefFormEX.getFileCode());
			BaseAction.getRequest().setAttribute("entityId", form.getId());
			BaseAction.getRequest().setAttribute("templateId",
					wfTemplateAttachmentRefFormEX.getId());
		}
		return WfConstant.MAKE_DOCUMENT;
	}
	

	/**
	 * 生成证书编号
	 * @return
	 */
	public String createZsbh() throws IOException{
		
		Map map=this.getMapByRequest(getRequest());	
		String taskId=(String) map.get("taskId");
		String actname=(String) map.get("actname");//经办人办结
		if(StringUtils.isNotBlank(taskId)){
			WfBusInstanceTaskForm instance = wfService.getWfBusInstanceTaskById(Long.valueOf(taskId), this.getLoginUserName());
			String activName=instance.getActivityName();
			if(actname.equals(activName)){
				String zsbh=csshljCzService.createZsbh(map,id);
				getResponse().getWriter().print(zsbh);
			}
		}
		return null;
	}
	
	/**
	 * 页面保存之前执行业务逻辑
	 */
	private void executeWfSaveServer() {
		Map<String, Object> map = new HashMap<String, Object>();
		HttpServletRequest request = BaseAction.getRequest();
		this.setEngineMap(map);
		ScriptEngine scriptEngine = ScriptEngineFactory
				.getBindingScriptEngine(map);
		formExecuteService.executeWfSaveServer(scriptEngine, request);
	}

	private void setEngineMap(Map map) {
		map.put("request", BaseAction.getRequest());
		map.put("response", BaseAction.getResponse());
		map.put("service", formExecuteService);
		map.put("page", page);
		map.put("pageMap", pageMap);
		map.put("testService", testService);
	}

	public String printcz() throws Exception {
		String taskId=getRequest().getParameter("taskInstDbid");
		if(StringUtils.isNotBlank(taskId)){
		  	WfBusInstanceTaskForm instance = wfService.getWfBusInstanceTaskById(Long.valueOf(taskId), this.getLoginUserName());
			String activName=instance.getActivityName();
		    getRequest().setAttribute("activName", activName);
		}else{
			 getRequest().setAttribute("activName", "");
		}
		if(form.getId() != null && form.getId() > 0){
			String templateCode = form.getTemplateCode();
			String fileCode = form.getFileCode();
			form =shljYsService.getForm(form.getId(), "SYSHLJ_V1");
			//加载收件通知书里面的附件
			form = shljYsService.getSjtzsField(form);
    		List<YwPrintDocForm> ywPrintDocFormList = ywPrintDocService.get(templateCode, fileCode, form.getId());
        	if(ywPrintDocFormList!=null && ywPrintDocFormList.size()>0){
    			return WfConstant.PRINT_DIR;
    		}
    	}
        return WfUtilsEX.wfBusPrint(form);
    }
	
	/**
	 * 加载历史意见到制文中
	 */
	private void setOpinions(){
		String viewName=getRequest().getParameter("viewName");
		if(viewName == null){
			throw new JbpmException("视图参数不能为空，无法正确加载历史意见列表！");
		}
		
		Map<String, List<TraceRecord>> map = null;
		if(viewName.equals(WfActElemPrivDefForm.DB_ZB_VIEW)){
			map = loadWfOpinionsByTaskInstDbid();
		}
		else{
			map = loadWfOpinionsByProcInstDbid();
		}		StringBuilder opinionsStr = new StringBuilder("");
		if(map != null){
               Iterator it=map.entrySet().iterator();
               while(it.hasNext()){
            	   Map.Entry entrys=(Map.Entry)it.next();
            	   String key=(String) entrys.getKey();
            	   List<TraceRecord> traceRecords = (List<TraceRecord>) entrys.getValue();
            	   this.setOpinion(key, traceRecords);
             }
		}
	}
	
	/**
	 * 环节名称判断是哪个环节的意见
	 */
	private void setOpinion(String hjmc, List<TraceRecord> traceRecords){
		StringBuilder opinionsStr = new StringBuilder("");
		if(traceRecords != null && traceRecords.size() > 0){
				for(TraceRecord traceRecord:traceRecords){
					if(traceRecord.getHandleComments() != null && traceRecord.getHandleComments().trim().length() > 0){
						opinionsStr.append(traceRecord.getHandleComments());
					}
				}
		}
		/*if("jbrsl".equals(hjmc)){//经办人受理
			form.setCsyj(opinionsStr.toString());
		}else if("czgldsh".equals(hjmc) || "cfgldsh".equals(hjmc)||"wfgldsh".equals(hjmc)){  //处分管领导审核或处主管领导审核
			String content=form.getFsyj()==null?"":form.getFsyj();
			if(StringUtils.isNotBlank(opinionsStr.toString())){
				content+=opinionsStr.toString()+"\n";
			}
			form.setFsyj(content);
		}else if("wzgldsp".equals(hjmc)){   //委主管领导审批
			form.setSpyj(opinionsStr.toString());
		}*/
		
	}
	

    /**
     * 设置form数据
     * @param form
     */
	private void reSetForm(ShljYsForm form){		
		this.shljYsService.reSetForm(form);
	}
	
	/**
	 * 窗口导入前检查
	 * @return
	 * @throws Exception
	 */	
	public String checkImportData() throws Exception{
        String id=getRequest().getParameter("id");
        String templateCode=getRequest().getParameter("templateCode");
        //先查询收件材料是否存在
        boolean flag=this.smartFormShljqsService.checkData(templateCode,"申请表",Long.valueOf(id),null);
        if(flag){
        }else{
            getResponse().getWriter().print("dataNotExist");
        }
	    
	    return null;
	}

	 /**
	  * 窗口收案环节导入数据
	  */
	public String  importData() throws Exception{
		Map map=getMapByRequest(getRequest());
		String contextPath=getRequest().getSession().getServletContext().getRealPath("");
		map.put("contextPath", contextPath);
		map.put("filename", "申请表");
		String result=this.shljYsService.importData(this.form,map);
		if(result==null)
			getResponse().getWriter().print("");
		else
			getResponse().getWriter().print(result);
		
		return null;
	}

    /**
     *获取返回后导入的数据
     * @return
     * @throws IOException 
     */
    public String getResultImportData () throws IOException{
    	String id=getRequest().getParameter("id");
       if(StringUtils.isNotBlank(id)){
    	   List list=this.shljYsService.getListById(Long.valueOf(id));
    	   Map map=(Map) list.get(0);
           JSONObject jsonObject = JSONObject.fromObject(map); 
           getResponse().getWriter().print(jsonObject.toString());
       }
        return null;
    }
    
    
	 private  Map getMapByRequest(HttpServletRequest request) {
	        Map<String, String> map = new HashMap<String, String>();
	        Enumeration enu = request.getParameterNames();
	        while(enu.hasMoreElements()) {   
	            String paraName = (String)enu.nextElement();   
	            String paraValue = request.getParameter(paraName).trim(); 
	           // if(paraValue!=null && !"".equals(paraValue)){
	                map.put(paraName, paraValue);
	            //}           
	        }
	                
	        return map;
	    } 

		
	public void doUpdateFym(){

		String id=getRequest().getParameter("fid");
		String fzsj=getRequest().getParameter("fzsj");
		String xmqy=getRequest().getParameter("xmqy");
		String fzh=getRequest().getParameter("fzh");
		String jysjs=getRequest().getParameter("jysjs");
		String jysje=getRequest().getParameter("jysje");
		String sql = "Update SYSHLJ_V1 SET FZH ='"
			+ fzh + "' , XMQY = '"
			+ xmqy+ "' , FZSJSTR = '"
			+ fzsj+ "' , JYSJESTR = '"
			+ jysje+ "' , JYSJSSTR = '"
			+ jysjs
			+ "' where ID = " + Long.parseLong(id);
		//smartDao.executeSql(sql);
	        
	}
	
	
	@Override
	public String delete() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String list() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	protected void prepareModel() throws Exception {
         if(form==null)
        	 form=new ShljYsForm();
         
         if(id!=null){
 			form =shljYsService.getForm(id, "SYSHLJ_V1");
 		}else{
 			form = new ShljYsForm();
 		}
	}
   
	
	public ShljYsForm getForm() {
		return form;
	}

	public void setForm(ShljYsForm form) {
		this.form = form;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Override
	public String save() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	public ShljYsForm getModel() {
		return form;
	}

}
